import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';

const typeOptions: Recordable[] = [
  {
    label: '记录型(多个记录)',
    value: '0',
  },
  // {
  //   label: '表单型(单个记录)',
  //   value: '1',
  // },
];
const cwsStatusOptions: Recordable[] = [
  {
    label: '不限',
    value: '-100',
  },
  {
    label: '流程已结束',
    value: '1',
  },
  {
    label: '流程未走完',
    value: '0',
  },
  {
    label: '流程被拒绝',
    value: '-2',
  },
  {
    label: '流程被放弃',
    value: '-3',
  },
];
export const columns: BasicColumn[] = [
  {
    title: '从模块名称',
    dataIndex: 'moduleName',
    width: 100,
    ellipsis: true,
    resizable: true,
    slots: { customRender: 'moduleName' },
  },
  {
    title: '选项卡名称',
    dataIndex: 'tabName',
    helpMessage: '如果为空则使用从模块名称',
    width: 100,
    ellipsis: true,
    resizable: true,
  },
  // {
  //   title: '主模块关联字段',
  //   dataIndex: 'relateField',
  //   width: 100,
  //   ellipsis: true,
  //   resizable: true,
  // },
  {
    title: '关联方式',
    dataIndex: 'relateType',
    width: 100,
    ellipsis: true,
    resizable: true,
    customRender: ({ text }) => {
      const obj = typeOptions.find((item) => item.value == text);
      if (obj) {
        return obj.label;
      }
      return '';
    },
  },
  {
    title: '顺序号',
    dataIndex: 'order',
    width: 100,
    ellipsis: true,
    resizable: true,
  },
  {
    title: '状态',
    dataIndex: 'cwsStatus',
    width: 100,
    ellipsis: true,
    resizable: true,
    customRender: ({ text }) => {
      const obj = cwsStatusOptions.find((item) => item.value == text);
      if (obj) {
        return obj.label;
      }
      return '';
    },
  },
  {
    title: '选项卡',
    dataIndex: 'is_on_tab',
    helpMessage: '是否显示于选项卡',
    width: 100,
    ellipsis: true,
    resizable: true,
    customRender: ({ text }) => {
      return text == 1 ? '是' : '否';
    },
  },
];

export const searchFormSchema: FormSchema[] = [];

export const formSchema: FormSchema[] = [
  {
    field: 'relateCode',
    label: '从模块',
    required: true,
    component: 'Input',
    colProps: { span: 24 },
    slot: 'relateCode',
  },
  {
    field: 'tabName',
    label: '选项卡名称',
    component: 'Input',
    colProps: { span: 24 },
    helpMessage: '如果为空则使用从模块名称',
  },
  {
    field: 'type',
    label: '关联方式',
    required: true,
    component: 'Select',
    colProps: { span: 24 },
    defaultValue: '0',
    componentProps: {
      options: typeOptions,
    },
  },
  {
    field: 'order',
    label: '顺序号',
    required: true,
    component: 'InputNumber',
    colProps: { span: 24 },
  },
  {
    field: 'cwsStatus',
    label: '状态',
    component: 'Select',
    required: true,
    colProps: { span: 24 },
    defaultValue: '1',
    componentProps: {
      options: cwsStatusOptions,
    },
  },
  {
    field: 'is_on_tab',
    label: '选项卡',
    component: 'Checkbox',
    colProps: { span: 24 },
    defaultValue: true,
    helpMessage: '是否显示于选项卡',
  },
  {
    field: 'conds',
    label: '配置条件',
    component: 'InputNumber',
    colProps: { span: 24 },
    helpMessage: '当满足条件时，显示从模块',
    slot: 'conds',
  },
];
export const otherFormFields = [
  {
    label: 'id',
    value: 'id',
  },
  {
    label: 'cwsId',
    value: 'cwsId',
  },
  {
    label: '无',
    value: '',
  },
];
